﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Reflection;

namespace DomPrint.Common
{
    class DomCommon
    {
        #region 提示消息
        /// <summary>
        /// 显示提示信息
        /// </summary>
        /// <param name="content">提示内容</param>
        public static void ShowMsg(string content)
        {
            MessageBox.Show(content, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        /// <summary>
        /// 显示询问信息
        /// </summary>
        /// <param name="content">提示内容</param>
        public static DialogResult ShowAsk(string content)
        {
            return MessageBox.Show(content, "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }

        /// <summary>
        /// 显示错误信息
        /// </summary>
        /// <param name="content">提示内容</param>
        public static void ShowError(string content)
        {
            MessageBox.Show(content, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        #endregion

        /// <summary>
        /// 获取配置项
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetConfigValue(string key)
        {
            return ConfigurationManager.AppSettings[key];
        }

        /// <summary>
        /// 获取当前程序集版本
        /// </summary>
        /// <returns></returns>
        public static string GetAssemblyFileVersion()
        {
            object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
            if (attributes.Length == 0)
            {
                return "";
            }
            else
            {
                return ((AssemblyFileVersionAttribute)attributes[0]).Version;
            }
        }
    }
}
